# @Author   : 懒羊羊
# @File     : yunSuan.py
# @Time     : 2024/11/29 16:21
import logging

from tools.dologs import DoLog

dolog = DoLog().set_get_logger(logging.INFO)


class DoYunSuan:
    num1 = None
    num2 = None

    def jia(self, num1, num2):
        if isinstance(num1, (int, float)) and isinstance(num2, (int, float)):
            try:
                dolog.info("开始做加法运算了！！！")
                result = num1 + num2
            except Exception as e:
                dolog.error(f"加法运算发生异常了，异常提示是：{e}")
            else:
                dolog.info("加法运算没有发生异常！！！")
                return result
            finally:
                dolog.info("加法运算结束了！！！")
        else:
            print("非法字符输入！！！")

    def jian(self, num1, num2):
        if isinstance(num1, (int, float)) and isinstance(num2, (int, float)):
            try:
                if isinstance(num1, float):
                    num1 = round(num1, 1)
                if isinstance(num2, float):
                    num2 = round(num2, 1)
                dolog.info("开始做减法运算了！！！")
                result = num1 - num2
                result = round(result, 1)
            except Exception as e:
                dolog.error(f"减法运算发生异常了，异常提示是：{e}")
            else:
                dolog.info("减法运算没有发生异常！！！")
                return result
            finally:
                dolog.info("减法运算结束了！！！")

    def cheng(self, num1, num2):
        if isinstance(num1, (int, float)) and isinstance(num2, (int, float)):
            try:
                dolog.info(f"开始做乘法运算了！！！{num1}, {num2}")
                result = num1 * num2
            except Exception as e:
                dolog.error(f"乘法运算发生异常了，异常提示是：{e}")
            else:
                dolog.info("乘法运算没有发生异常！！！")
                return result
            finally:
                dolog.info("乘法运算结束了！！！")

    def chu(self, num1, num2):
        if num2 == 0:
            print("除数不能是0！！！")
        else:
            if isinstance(num1, (int, float)) and isinstance(num2, (int, float)):
                try:
                    dolog.info("开始做除法运算了！！！")
                    result = num1 / num2
                except Exception as e:
                    dolog.error(f"除法运算发生异常了，异常提示是：{e}")
                else:
                    dolog.info("除法运算没有发生异常！！！")
                    return result
                finally:
                    dolog.info("除法运算结束了！！！")
